{% load staticfiles %}
<div class="breadcrumbs ace-save-state" id="breadcrumbs">
	<ul class="breadcrumb">
		<li>
			<i class="ace-icon fa fa-list-alt"></i>
			<a href="javascript:void(0)">资料审核</a>
		</li>
		<li class="active">企业审核</li>
	</ul><!-- /.breadcrumb -->

	<div class="nav-search" id="nav-search">

	</div><!-- /.nav-search -->
</div>

<div class="page-content">

	<div class="row" id="page_erpinfo_list">
		<div class="widget-box widget-color-blue">
			<div class="widget-header">
				<h5 class="widget-title">待审核企业列表</h5>

				<div class="widget-toolbar">
					<a href="#" data-action="collapse">
						<i class="1 ace-icon fa fa-chevron-up bigger-125"></i>
					</a>
				</div>

			</div>

			<div class="widget-body">

				<div class="widget-main">
					<div class="row">

						<div class="col-xs-12">
							<!-- PAGE CONTENT BEGINS -->
							<table id="erpinfo-grid-table"></table>
							<div id="erpinfo-grid-pager"></div>
							<!-- PAGE CONTENT ENDS -->
						</div><!-- /.col -->
					</div>
				</div>

			</div>
		</div>
	</div>

	<div class="row" id="page_erpinfo_detail">


	</div>
</div><!-- /.page-content -->

<script src="{% static 'smAdmin/js/ErpInfoChecker.js' %}"></script>

<script type="text/javascript">

	user_page_init();

	function user_page_init() {
		$("#check_status_select").select2({minimumResultsForSearch: -1});

		var grid_selector = "#erpinfo-grid-table";
		var pager_selector = "#erpinfo-grid-pager";

		// 初始化
		var grid_config ={{ grid_config|safe }};

		function style_edit_form_field(form) {

		}

		// 操作列
		JqGridHelp.updateColModel(grid_config, "myac",
			{
				formatoptions: {
					keys: true,

					editbutton: true,
					editformbutton: false,
					onEdit: null,
					onSuccess: null,
					afterSave: null,
					onError: null,
					afterRestore: null,
					extraparam: {my: 'my'},
					editOptions: {
						recreateForm: true,
						beforeShowForm: JqGridHelp.beforeEditCallback
					},

					delbutton: true,
					delOptions: {
						recreateForm: true,
						beforeShowForm: JqGridHelp.beforeDeleteCallback
					}
				}
			}
		);

		function formatLink(cellValue, options, rowObject) {
			return '<a href="javascript:void(0)" onclick="ErpInfoChecker.loadErpInfoDetail(' + rowObject.id + ')" >' + cellValue + '</a>';
		}

		function formatCheckStatus(cellValue, options, rowObject) {
			if (cellValue === 0) {
				return "未提交";
			} else if (cellValue === 1) {
				return "待审核";
			} else if (cellValue === 2) {
				return "通过";
			} else if (cellValue === 3) {
				return "驳回";
			}
		}

		function formatMyAc(cellValue, options, rowObject, state) {
			var detail = '<div title="审核" style="float:left;cursor:pointer;" ' +
				'class="ui-pg-div ui-inline-edit"' +
				'onclick="ErpInfoChecker.loadErpInfoDetail(' + rowObject.id + ');" ' +
				'onmouseover="jQuery(this).addClass(\'ui-state-hover\');" ' +
				'onmouseout="jQuery(this).removeClass(\'ui-state-hover\');">' +
				'<span class="ui-icon ui-icon-pencil"></span>' +
				'</div>';

			return '<div style="margin-left:8px;">' + detail + '</div>'
		}

		JqGridHelp.updateColModel(grid_config, "full_name", {formatter: formatLink});
		JqGridHelp.updateColModel(grid_config, "check_status", {formatter: formatCheckStatus});
		JqGridHelp.updateColModel(grid_config, "myac", {formatter: formatMyAc});

		var jqGridHelp = JqGridHelp.createNew(grid_selector, pager_selector, grid_config, style_edit_form_field);
		// 隐藏标题
		$(".ui-jqgrid-titlebar").hide();

		ErpInfoChecker.showPageErpInfoList();
	}


</script>